home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / alv.sun / alv.lha / src / rasval.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-08  |  1.8 KB  |  83 lines

  1. #include <stdio.h>
  2. #include "defs.h"
  3.  
  4. #define               BOLD_ON         "\033[7m"
  5. #define               BOLD_OFF        "\033[m"
  6.  
  7. har   *progname;
  8. har   *filename;
  9. ixrect *pr1, *pr2;
  10.  
  11. #ifdef STANDALONE
  12. ain(argc, argv, envp)
  13. #else
  14. asval_main(argc, argv, envp)
  15. #endif
  16.     int     argc;
  17.     char  **argv;
  18.     char  **envp;
  19. {
  20.     register int i, j;
  21.     int     noheaders, xoffset, yoffset, xsize, ysize;
  22.     colormap_t    colormap;
  23.  
  24.     noheaders = xsize = ysize = xoffset = yoffset = 0;
  25.     progname = strsave(argv[0]);
  26.     parse_profile(&argc, argv, envp);
  27.  
  28.     while ((gc = getopt(argc, argv, "nx:y:X:Y:")) != EOF)
  29.         switch (gc) {
  30.         case 'x':
  31.             xoffset = atoi(optarg);
  32.             break;
  33.         case 'y':
  34.             yoffset = atoi(optarg);
  35.             break;
  36.         case 'X':
  37.             xsize = atoi(optarg);
  38.             break;
  39.         case 'Y':
  40.             ysize = atoi(optarg);
  41.             break;
  42.         case 'n':
  43.             noheaders++;
  44.             break;
  45.         case '?':
  46.             errflag++;
  47.             break;
  48.         }
  49.  
  50.     if (errflag)
  51.         error((char *) 0, "Usage: %s: [-n] [-x xoffset] [-y yoffset] [-X xsize] [-Y Ysize] [infile]\n", progname);
  52.  
  53.     for (stream = 0; optind < argc; stream++, optind++)
  54.         if (stream == 0 && strcmp(argv[optind], "-") != 0)
  55.             if (freopen(argv[optind], mode[stream], f[stream]) == NULL)
  56.                 error("%s %s", PR_IO_ERR_INFILE, argv[optind]);
  57.  
  58.     if ((pr1 = pr_load(stdin, &colormap)) == NULL)
  59.         error(PR_IO_ERR_RASREAD);
  60.  
  61.     if (xsize == 0)
  62.         xsize = 10;
  63.     if (ysize == 0)
  64.         ysize = 10;
  65.  
  66.     if ((pr2 = pr_region(pr1, xoffset, yoffset, xsize, ysize)) == NULL)
  67.         error("pr_region returned NULL");
  68.  
  69.     if (!noheaders) {
  70.         printf("       %s", BOLD_ON);
  71.         for (i = 0; i < pr2->pr_size.x; i++)
  72.             printf("%6d", xoffset + i);
  73.         putchar('\n');
  74.     }
  75.     for (j = 0; j < pr2->pr_size.y; j++) {
  76.         if (!noheaders)
  77.             printf("%s%7d%s", BOLD_ON, yoffset + j, BOLD_OFF);
  78.         for (i = 0; i < pr2->pr_size.x; i++)
  79.             printf("%6d", pr_get(pr2, i, j));
  80.         putchar('\n');
  81.     }
  82. }
  83.